<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<title></title>
	<style type="text/css">
		*{
			margin: 0;
			padding: 0;
		}
		.father{
			width: 300px;
			height: 300px;
			background-color: skyblue;
			position: relative;
			padding: 20px;
			margin: 30px;
			border: 20px solid #ccc;
		}
		.son{
			width: 70px;
			height: 70px;
			background-color: pink;
			position: absolute;
			margin: 30px;
			top: 50px;
			left: 50px;
		}
	</style>
</head>
<body>

<div class="father">
	<div class="son"></div>
</div>
<script type="text/javascript">
	let son = document.querySelector('.son')

	//偏移量
	console.log('对于左侧的偏移量',son.offsetLeft)
	console.log('对于顶部的偏移量',son.offsetTop)

	//在不脱标的情况下 offsetLeft/offsetTop 取决于父元素的margin，padding，border 和子元素的margin

	//在脱标的情况下只取决于自身的left/top + margin
</script>
</body>
</html>